package org.gnomus.util;

import java.util.HashMap;
import java.util.Map;

public class time {

    private static final ThreadLocal<Map<String, Long>> tl = new ThreadLocal<Map<String, Long>>();
    public static void trace(String key) {
        Map<String, Long> m;
        synchronized (tl) {
            m = tl.get();
            if (m == null) {
                m = new HashMap<String, Long>();
                tl.set(m);
            }
        }
        Long t = m.remove(key);
        if (t == null) {
            t = System.currentTimeMillis();
            m.put(key, t);
        } else {
            System.out.println(key + " time: " + (System.currentTimeMillis() - t) + " milliseconds");
        }
    }
}
